package GUITOOl;

import Entity.User;
import Utils.ImageIconUtils;

import javax.swing.*;
import java.awt.*;

/**
 * The type Fri list cell renderer.
 *
 * @author wyc, zry
 * @version 1.0
 */
@SuppressWarnings({ "rawtypes", "serial" })
public class FriListCellRenderer  extends JLabel implements ListCellRenderer {
    @Override
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                                                  boolean cellHasFocus) {
        User user=(User) value;
        String text="<html>"+user.getUsername() + "     id: " + user.getUid() + "<br/>" + user.getSex()  + "    生日："+ user.getBirthday() + " <html/>";
        setText(text);
        setFont(new Font("宋体",0,14));

        Image img= (ImageIconUtils.getProfile(user.getProfileID(), 300, 300)).getImage().getScaledInstance(80, 80, Image.SCALE_DEFAULT);
        ImageIcon i=new ImageIcon(img);
        setIcon(i);
        setIconTextGap(80);
        return this;
    }
}